const Router = require('koa-router');

const {tokenValidator} = require('../middleware/auth.middleware');
const {blocksFormValidator, idValidator} = require('../middleware/validate.middleware');
// 业务路由拆分 -- controller层
const {addBlocks, updateBlocks, queryBlocks, queryBlocksDetail, deleteBlocks} = require('../controller/blocks.controller');

// 统一前缀
const router = new Router({prefix: '/blocks'});

// 增删改查
router.post('/add', tokenValidator, blocksFormValidator, addBlocks);
router.post('/update', tokenValidator, idValidator, blocksFormValidator, updateBlocks);
router.get('/list', tokenValidator, queryBlocks);
router.get('/detail', tokenValidator, idValidator, queryBlocksDetail);
router.post('/delete', tokenValidator, idValidator, deleteBlocks);


module.exports = router;